import '@/assets/css/main.scss';
// import EasyPlayer from '@easydarwin/easyplayer';
import axios from 'axios';
import * as echarts from 'echarts';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import Vue from 'vue';
import Vuex from 'vuex';
import App from './App.vue';
import PlayVideo from './store/playvideo';
import WebsocketClient from './store/websocketclients';
// import SocketModule from './store/socketio';

Vue.use(ElementUI);
// Vue.use(EasyPlayer);
Vue.use(Vuex);

Vue.prototype.$echarts = echarts;

Vue.config.productionTip = false;

const store = new Vuex.Store();
store.registerModule('playVideo', PlayVideo);
// store.registerModule('socketIO', SocketModule)
store.registerModule('websocketClient', WebsocketClient);

loadConfig().then(() => {
  new Vue({
    store,
    render: (h) => h(App),
  }).$mount('#app');
});

// 定义一个函数来加载配置
function loadConfig() {
  return axios
    .get('/config.json')
    .then((response) => response.data)
    .then((config) => {
      // 将配置存储在 Vuex store 中
      store.commit('websocketClient/SET_CONFIG', config);
      // store.commit('socketIO/SET_SOCKET', config);
    })
    .catch((error) => {
      console.error('Failed to load config:', error);
      return {};
    });
}
